﻿<!--*********************************************************************

   Extended WPF Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   This program can be provided to you by Xceed Software Inc. under a
   proprietary commercial license agreement for use in non-Open Source
   projects. The commercial version of Extended WPF Toolkit also includes
   priority technical support, commercial updates, and many additional 
   useful WPF controls if you license Xceed Business Suite for WPF.

   Visit http://xceed.com and follow @datagrid on Twitter.

  ********************************************************************-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters;assembly=WPFToolkit.Extended"
                    xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes;assembly=WPFToolkit.Extended"
                    xmlns:local="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended">
                    <!--xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes"
                    xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters"
                    xmlns:local="clr-namespace:Xceed.Wpf.Toolkit">-->

    <conv:InverseBoolConverter x:Key="InverseBoolConverterNew" />

    <LinearGradientBrush x:Key="PopupDarkBorderBrushNew" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFA3AEB9" Offset="0" />
        <GradientStop Color="#FF8399A9" Offset="0.375" />
        <GradientStop Color="#FF718597" Offset="0.375" />
        <GradientStop Color="#FF617584" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="PopupBackgroundBrushNew" StartPoint="0,0" EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Offset="0" Color="#FFffffff" />
                <GradientStop Offset="1" Color="#FFE8EBED" />
            </GradientStopCollection>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>

    <Style TargetType="{x:Type chrome:ButtonChrome}" x:Key="ButtonChromeStyle">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Background" Value="{StaticResource AreaHeaderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type chrome:ButtonChrome}">
                    <Grid>

                        <Border x:Name="OuterBorder" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{x:Null}" Background="{StaticResource AreaHeaderBrush}">
                        </Border>
                        <ContentPresenter Margin="{TemplateBinding Padding}"
										      IsEnabled="{TemplateBinding IsEnabled}"
										      Content="{TemplateBinding Content}"
										      ContentStringFormat="{TemplateBinding ContentStringFormat}"
										      ContentTemplate="{TemplateBinding ContentTemplate}"
										      ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!-- if not rendered normally -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderNormal" Value="False" />
                                <Condition Property="RenderChecked" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="Transparent" />
                            <!--<Setter TargetName="InnerBorder" Property="BorderBrush" Value="{x:Null}" />-->
                            <Setter TargetName="OuterBorder" Property="Background" Value="Transparent" />
                        </MultiTrigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:DropDownButton}" x:Key="DropDownButtonStyleCustom">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="Foreground" Value="{StaticResource AreaHeaderForegroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DropDownButton}">
                    <Grid x:Name="MainGrid" SnapsToDevicePixels="True">
                        <ToggleButton x:Name="PART_DropDownButton"
                                Grid.Column="1"
                                IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverterNew}}" Foreground="{StaticResource AreaHeaderForegroundBrush}">
                            <ToggleButton.Template>
                                <ControlTemplate TargetType="ToggleButton">
                                    <ContentPresenter />
                                </ControlTemplate>
                            </ToggleButton.Template>
                            <Grid>
                                <chrome:ButtonChrome x:Name="ToggleButtonChrome" Style="{StaticResource ButtonChromeStyle}"
                                             CornerRadius="0"
                                             RenderChecked="{TemplateBinding IsOpen}"
                                             RenderEnabled="{TemplateBinding IsEnabled}"
											            RenderMouseOver="{Binding IsMouseOver, ElementName=PART_DropDownButton}"
											            RenderPressed="{Binding IsPressed, ElementName=PART_DropDownButton}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <ContentPresenter Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="true" />
                                        <Grid x:Name="arrowGlyph" IsHitTestVisible="False" Margin="4,3,4,3" Grid.Column="1">
                                            <Path Width="7" Height="4" Data="M 0 0 L 4 4 L 8 0 Z" Fill="{StaticResource AreaHeaderForegroundBrush}" />
                                        </Grid>
                                    </Grid>
                                </chrome:ButtonChrome>
                            </Grid>
                        </ToggleButton>

                        <Popup x:Name="PART_Popup" 
                         HorizontalOffset="1"
                         VerticalOffset="1"
                         AllowsTransparency="True"
                         StaysOpen="False"
                         Placement="Bottom"
                         Focusable="False"
                         IsOpen="{Binding IsChecked, ElementName=PART_DropDownButton}">
                            <Border BorderThickness="1" Background="{StaticResource PopupBackgroundBrushNew}" BorderBrush="{StaticResource PopupDarkBorderBrushNew}">
                                <ContentPresenter Content="{TemplateBinding DropDownContent}" />
                            </Border>
                        </Popup>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
